#coding=utf-8

require "aio/core"

class Aio::Module::Cmd::Cisco::ShowFailover < Aio::Module::Cmd::Cisco
	
	include Aio::Module

	def initialize
		super({
			:cmd_full				=> "show failover",
			:cmd_short			=> "sh fail",
			:author					=> "Elin",
			:description		=> "This is Cisco ASA Command# show failover",
			:ranking				=> Ranking_1,
			:platform				=> FW,
		})
	end

	def parse
		context = self.context.dup
		failover = {}
		useful[:failover] = failover
		context.readline_match_block(/Failover (?<status>.*)/) do |block|
			block.update(failover, :status)
		end

		if failover[:status] =~ /On/
			context.readline_match_block(/Failover unit (?<standby>.*)/) do |block|
				block.update(failover, :standby)
			end
			context.readline_match_block(/Failover LAN Interface: failover (?<interface>[^\s]+) \((?<interface_status>[^\)]+)\)/) do |block|
				block.update(failover, :interface)
				block.update(failover, :interface_status)
			end
		end
	end
end

